package com.youlemall.manager.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.youlemall.common.pojo.PageResult;
import com.youlemall.pojo.Goods;
import com.youlemall.service.GoodsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**待审核商品列表控制器
 * 2 * @Author: kevin
 * 3 * @Date: 2019/7/22 16:34
 * 4
 */

@RestController
@RequestMapping("/goods")
public class GoodsController {


	@Reference
	private GoodsService goodsService;

	/**
	 * 待审核商品列表分页查询
	 * @param page
	 * @param goods
	 * @param rows
	 * @return
	 */
	@GetMapping("/findByPage")
	public PageResult findByPage(Integer page, Goods goods,
								 @RequestParam(defaultValue = "10") Integer rows){
		goods.setAuditStatus("0");
		return goodsService.findByPage(goods,page,rows);
	}



	@GetMapping("/updateStatus")
	public boolean updateStatus(Long[] ids,String status){
		try {
			goodsService.updateStatus("audit_status",ids,status);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}


	@GetMapping("/delete")
	public boolean deleteStatus(Long[] ids){
		try {
			goodsService.updateStatus("is_delete",ids,"1");
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
}
